package com.fit.entities;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;

@Entity
@Table(name = "licence_plate")
public class LicencePlate {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NonVisual
	@Column(name = "id")
	private Long id;
	@Validate("required")
	@Column(name = "licence_plate_number", nullable = false)
	private String licencePlateNo;
	@Validate("required")
	@Column(name = "date_created", nullable = false)
	private Date date;
	@Validate("required")
	@ManyToOne(optional = false)
	@JoinColumn(name = "registration_client")
	private Client client;
	@Validate("required")
	@ManyToOne(optional = false)
	@JoinColumn(name = "registration_vehicle")
	private Vehicle vehicle;
	@Validate("required")
	@Column(name = "traffic_license_number", nullable = false)
	private Long trafficLicenseNo;

	public String getLicencePlateNo() {
		return licencePlateNo;
	}

	public void setLicencePlateNo(String licencePlateNo) {
		this.licencePlateNo = licencePlateNo;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Vehicle getVehicle() {
		return vehicle;
	}

	public void setVehicle(Vehicle vehicle) {
		this.vehicle = vehicle;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getTrafficLicenseNo() {
		return trafficLicenseNo;
	}

	public void setTrafficLicenseNo(Long trafficLicenseNo) {
		this.trafficLicenseNo = trafficLicenseNo;
	}

	public Date getDate() {
		return date;
	}
	
	public String getDateFormat() {
		SimpleDateFormat sf = new SimpleDateFormat("dd.MM.yyyy");
		String s = sf.format(date);
		return s;
	}

	public void setDate(Date date) {
		this.date = date;
	}

}
